package cn.yusei.teamTribe.entity;

import cn.yusei.teamTribe.util.StringUtil;

public class Post {

	private int id;
	private String title; //16
	private String content;  //21845
	private String createTime;
	private String editTime;
	private int targetId;  //如果是帖子，值为0，如果是评论表示评论的对象
	private int comCnt; //该帖子或评论拥有的评论的次数
	
	public boolean isValid()
	{
		if(content == null || StringUtil.lengthAbove(content, 21845))
			return false;
		if(targetId < 0)
			return false;
		if(targetId == 0)  //帖子不是评论时必须有合法标题
		{
			if(title == null || title.length() == 0 || StringUtil.lengthAbove(title, 16))
				return false;
		}
		else if(title != null)  //为评论时不能有标题
			return false;
		return true;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getTitle()
	{
		return title;
	}
	public void setTitle(String title)
	{
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getEditTime() {
		return editTime;
	}
	public void setEditTime(String editTime) {
		this.editTime = editTime;
	}
	public int getTargetId() {
		return targetId;
	}
	public void setTargetId(int targetId) {
		this.targetId = targetId;
	}
	public int getComCnt() {
		return comCnt;
	}
	public void setComCnt(int comCnt) {
		this.comCnt = comCnt;
	}

	@Override
	public String toString() {
		return "Post [id=" + id + ", title=" + title + ", content=" + content + ", createTime=" + createTime
				+ ", editTime=" + editTime + ", targetId=" + targetId + ", comCnt=" + comCnt + "]";
	}
	
}
